package com.vclee.fast.controller.user;

import com.vclee.fast.utils.SnowUtils;
import com.vclee.fast.utils.aspect.OpenServe;
import com.vclee.fast.utils.aspect.SysLog;
import com.vclee.fast.utils.exception.R;
import com.vclee.fast.utils.model.WxPayReq;
import com.vclee.fast.utils.sdk.WxUtil;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;
import java.util.UUID;

@OpenServe
@RestController
@RequiredArgsConstructor
@RequestMapping("user-service")
public class UserController {
    @SysLog("发起支付购买会员卡")
    @PostMapping("createPayOrder")
    public R sendCaptcha() {
        WxPayReq req = new WxPayReq();
        req.setOrdId(SnowUtils.getStrKey());
        req.setTitle("会员卡购买");
        req.setPrice(new BigDecimal("0.01"));
        req.setOpenId("oZ5uQ7dKOzNbABx3X0bmxkAmRSYY");
        req.setAttach(UUID.randomUUID().toString());
        req.setCallbackUrl("https://www.bcwd.cc/fq-server-test/openapi-service/wxPayV3Notify");
        req.setAppid("wxd7029c6a261ef094");
        req.setMchId("1696681777");
        req.setApiV3Key("LTAI5tR8C8AsigUx4P56fuqiao202412");
        req.setApiV3MchNo("2899C132AE6905DEDBA99FEDF4A47C5DDB0EF7DC");
        req.setApiV3MchCertPath("D:\\workspace\\server-fast\\src\\main\\resources\\cert\\fqh\\apiclient_key.pem");
        req.setPayType(1);
        return R.ok(WxUtil.wxPayV3CreateAppletOrder(req));
    }
}
